<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>$provider</title>
</head>
<body ng-app="myApp" ng-controller="firstController">
<div ng-bind="name"></div>
</body>
</html>

<script src="../libs/AngularJS.min.js"></script>
<script>
    angular
        .module('myApp', [], function ($provide) {
            $provide.provider('Customer', function () {
                this.$get = function () {
                    return {
                        message: '这是自定义的服务!'
                    }
                }
            });

            // 自定义工厂   可以返回任何数据类型
            $provide.factory('Customer2', function () {
                return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
            });

            //自定义服务   返回的必须是一个对象
            $provide.service('CustomerService', function () {
                return {city: '上海'};
            });
        })
        .controller('firstController', ['Customer', '$scope', 'Customer2', 'CustomerService', function (Customer, $scope, Customer2, CustomerService) {
            $scope.name = '张三';
            console.log(Customer.message)
            console.log(Customer2);
            console.log(CustomerService)
        }]);
</script>